package com.study.project.config.exception;

import org.springframework.web.bind.annotation.RestControllerAdvice;

import lombok.extern.slf4j.Slf4j;

/**
 * @program: studyProject
 * @description:
 * @author: yangjie
 * @create: 2024-04-13 15:26
 **/
@Slf4j
@RestControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(value = Exception.class)
    public Response handleException(Exception exception) {
        String message = exception.getMessage();
        return Response.error(ErrorCode.REMOTE_INVOKE_ERROR.getCode(), message);
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(value = RuntimeException.class)
    public Response handleRuntimeException(RuntimeException exception) {
        String message = exception.getMessage();
        return Response.error(ErrorCode.REMOTE_INVOKE_ERROR.getCode(), message);
    }
}